package com.lipy.springootrabbitmq.config.topic;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @description:
 * @author: lipy
 * @create: 2020-09-22 22:33
 **/
@Component
@RabbitListener(queues = "topic.All")
public class TopicReceiveAll {
    @RabbitHandler
    public void handle(String message, Channel channel, Message mm){
        System.out.println("topic.All recevie message = " + message);
        try {
            channel.basicAck(mm.getMessageProperties().getDeliveryTag(),false);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
//   自动确认模式
//    @RabbitHandler
//    public void handle(String message){
//        System.out.println("topic.All recevie message = " + message);
//    }
}
